<?php
/*
 * @Create By: Vscode
 * @Author: falcon
 * @Date: 2021-02-15 23:18:25
 * 同步星爱订单状态 order 与 order_info 的create_time ， 一次性
 */
namespace application\controller;

use application\depend\Applog;
use application\model\PdoModel;
class SyncOrderCreateTime{

    public function main(){
        
        $sql = "select * from `order` where create_time is not null";
        $orderRes = PdoModel::selectData($sql,[],'主订单表订单和状态信息！');

        if(!empty($orderRes)){
            foreach($orderRes as $v){
                $order_num = $v['order_number'];
                
                $sql = "update order_info set status={$status} where order_number='{$order_num}'";
                if(false === PdoModel::selectData($sql,[],'更新订单详情表订单状态')){
                    Applog::errorLog(['title'=>'更新订单详情表订单状态出错！','sql'=>$sql,'date'=>date('Ymd His')]);
                    return '更新出错了！'.PHP_EOL;
                }
            }// foreach

            return '更新成功！'.PHP_EOL;
        }// if

        return '主订单表无任何数据！'.PHP_EOL;
    }// func

}// class